﻿using System;
using System.Windows.Controls;
using System.Windows.Navigation;
using Infragistics.Controls.Menus;

namespace StartupSolution.Views.Menus.BuildingRibbon
{
    public partial class RibbonCodeBehind : Page
    {
        private const string ImgPathRibbonAppMenu = "/StartupSolution;component/Images/RibbonAppMenu.png";
        private const string ImgPathRibbonOpen = "/StartupSolution;component/Images/RibbonOpen.png";
        private const string ImgPathRibbonBold = "/StartupSolution;component/Images/RibbonBold.png";
        private const string ImgPathRibbonItalic = "/StartupSolution;component/Images/RibbonItalic.png";
        private const string ImgPathRibbonUnderline = "/StartupSolution;component/Images/RibbonUnderline.png";

        public RibbonCodeBehind()
        {
            InitializeComponent();

            // Create a XamRibbon object
            XamRibbon ribbon = new XamRibbon();

            // Customize the XamRibbon Application menu

            // Set an image to the XamRibbon Application menu
            ribbon.ApplicationMenu.Image = new Uri(ImgPathRibbonAppMenu, UriKind.Relative);

            ribbon.ApplicationMenu.RecentItemsHeader = "Recent Items";
            
            // Create a Button tool and add it to the XamRibbon control application menu
            ButtonTool appMenuOpenBtn = new ButtonTool();
            appMenuOpenBtn.Caption = "Open";
            appMenuOpenBtn.LargeImage = new Uri(ImgPathRibbonOpen, UriKind.Relative);
            ribbon.ApplicationMenu.Items.Add(appMenuOpenBtn);

            // TODO: Add more tools as items to the XamRibbon Application menu

            // TODO: Refer to the online documentation how to create a list with the recent items in the XamRibbon Application menu 
            
            // Create a XamRibbon tab item
            XamRibbonTabItem tabItemHome = new XamRibbonTabItem();
            tabItemHome.Header = "Home";

            // Create a XamRibbonGroup named 'Font'
            XamRibbonGroup fontGroup = new XamRibbonGroup();
            fontGroup.Caption = "Font";

            // Create a HorizontalRibbonToolContainer to position the contained tools
            HorizontalRibbonToolContainer container = new HorizontalRibbonToolContainer();

            // Create a ButtonTool 
            ButtonTool boldButton = new ButtonTool();
            boldButton.MaximumSize = RibbonToolSizingMode.ImageOnly;
            boldButton.SmallImage = new Uri(ImgPathRibbonBold, UriKind.Relative);
            container.Tools.Add(boldButton);

            ButtonTool italicButton = new ButtonTool();
            italicButton.MaximumSize = RibbonToolSizingMode.ImageOnly;
            italicButton.SmallImage = new Uri(ImgPathRibbonItalic, UriKind.Relative);
            container.Tools.Add(italicButton);

            // TODO: Add more buttons in the group horizontal container in the XamRibbon control

            // ButtonTool underlineButton = new ButtonTool();
            // underlineButton.MaximumSize = RibbonToolSizingMode.ImageOnly;
            // underlineButton.SmallImage = new Uri(ImgPathRibbonUnderline, UriKind.Relative);
            // container.Tools.Add(underlineButton);

            // Add the HorizontalRibbonToolContainer to the XamRibbon goup tools collection
            fontGroup.Tools.Add(container);

            // Add the created group to the XamRibbonTabItem Groups collection
            tabItemHome.Groups.Add(fontGroup);

            // Create a XamRibbonGroup named 'Paragraph'
            XamRibbonGroup paragraphGroup = new XamRibbonGroup();
            paragraphGroup.Caption = "Paragraph";
            tabItemHome.Groups.Add(paragraphGroup);

            // TODO: Add more groups in the tabs in the XamRibbon control 

            ribbon.Tabs.Add(tabItemHome);

            // TODO: Add more tabs in the XamRibbon control

            LayoutRoot.Children.Add(ribbon);
            Grid.SetRow(ribbon, 2);
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

    }
}
